home *** CD-ROM | disk | FTP | other *** search
/ SunSoft Catalyst CDWARE 1996 May to August / Catalyst CDWARE 1996 May to August.iso / .products / .bin / httpd / src / http_post.c < prev    next >
C/C++ Source or Header  |  1995-05-18  |  2KB  |  63 lines

  1. /*
  2.  * http_post.c: Handles POST
  3.  * 
  4.  * All code contained herein is covered by the Copyright as distributed
  5.  * in the README file in the main directory of the distribution of 
  6.  * NCSA HTTPD.
  7.  *
  8.  * Based on NCSA HTTPd 1.3 by Rob McCool
  9.  * 
  10.  */
  11.  
  12. #include "httpd.h"
  13.  
  14. void handle_post(char *name, char *args, int in, FILE *out) {
  15.     struct stat finfo;
  16.     char ct_bak[MAX_STRING_LEN];
  17.  
  18.     strcpy(ct_bak,content_type); /* oop ack */
  19.     if(stat(name,&finfo) == -1) {
  20.         if(find_script("POST",name,args,in,out))
  21.             return;
  22.         if(errno==ENOENT) {
  23.             log_reason("file does not exist",name);
  24.             unmunge_name(name);
  25.             die(NOT_FOUND,name,out);
  26.         }
  27.         else {
  28.             log_reason("file permissions deny server access",name);
  29.             unmunge_name(name);
  30.             die(FORBIDDEN,name,out);
  31.         }
  32.     }
  33.     probe_content_type(name);
  34.     if(!strcmp(content_type,CGI_MAGIC_TYPE)) {
  35.         strcpy(content_type,ct_bak);
  36.         send_cgi("POST",name,"",args,&finfo,in,out);
  37.         return;
  38.     }
  39.     /* Not a script, do group ann thang */
  40.     die(NOT_IMPLEMENTED,"POST to non-script",out);
  41. }
  42.  
  43.  
  44.  
  45. void post_node(char *name, char *args, int in, FILE *out) {
  46.     int s;
  47.  
  48.     s=translate_name(name,out);
  49.  
  50.     switch(s) {
  51.       case STD_DOCUMENT:
  52.         handle_post(name,args,in,out);
  53.         return;
  54.       case REDIRECT_URL:
  55.         die(REDIRECT,name,out);
  56.       case SCRIPT_NCSA:
  57.         exec_post_NCSA(name,args,in,out);
  58.         return;
  59.       case SCRIPT_CGI:
  60.         exec_cgi_script("POST",name,args,in,out);
  61.     }
  62. }
  63.